<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<div class="modal-dialog x-modal-dialog" style="width: 600px;margin-top: 150px;">

  <div class="modal-content">
  
    <div class="modal-header x-breadcrumb clearfix">

      <h2><i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>编辑账户</span></h2>
      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>
    
    <form class="form-horizontal" method="POST" action="${ctx.host}/principals/${principal.id}" data-validate="true">

      <input type="hidden" name="_method" value="PATCH" >
      <input type="hidden" name="id" value="${principal.id}" >

      <div class="modal-body">
      
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">用户名称：</label>
          <div class="pull-left col-xs-6">
            <p class="form-control-static">${principal.name}</p>
          </div>
        </div>

        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">手机号码：</label>
          <div class="pull-left col-xs-6">
            <input name="mobile" type="text" class="form-control" value="${principal.mobile}" data-validate="required|mobile">
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">用户权限：</label>
          <div class="pull-left col-xs-6">
            <p class="form-control-static">${secure.roles[principal.authority].description}</p>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="control-label col-xs-4">是否后台登录：</label>
          <div class="pull-left col-xs-6">
            <input id="checkbox-admin" ${principal.admin ? 'checked':''} type="checkbox" data-on-color="success" data-off-color="warning" data-on-text="是" data-off-text="否" />
            <input id="input-admin" name="admin" type="hidden" class="form-control" value="${principal.admin}" />
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="control-label col-xs-4">是否企业号登录：</label>
          <div class="pull-left col-xs-6">
            <input id="checkbox-enterprise" ${principal.enterprise ? 'checked':''} type="checkbox" data-on-color="success" data-off-color="warning" data-on-text="是" data-off-text="否" />
            <input id="input-enterprise" name="enterprise" type="hidden" class="form-control" value="${principal.enterprise}" />
          </div>
        </div>
        
      </div>

      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>

    </form>
  </div>
</div>

<script type="text/javascript">
  $(function(){
    
    $('#checkbox-enterprise').bootstrapSwitch({
      onSwitchChange: function(event, state) {
        $('#input-enterprise').val(state ? 'true' : 'false');
      }
    });
    
    $('#checkbox-admin').bootstrapSwitch({
       onSwitchChange: function(event, state) {
         $('#input-admin').val(state ? 'true' : 'false');
       }
     });
    
  })
</script>